package com.myproject.base;

import java.util.ArrayList;
import java.util.List;

public class Test6 {

    public static void main(String[] args) throws InterruptedException {


        Runtime runtime = Runtime.getRuntime();
        System.out.println("可用最大内存：" + runtime.maxMemory()/(1024*1024));
        System.out.println("当前可用内存：" + runtime.totalMemory()/(1024*1024));

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {

                List<BigBoy> list = new ArrayList<>();
                for (int i = 0; i < 10000; i++) {
                    list.add(new BigBoy());
                    if (i%10==0){
                        System.out.println(i);
                        System.out.println("空闲内存：" + runtime.freeMemory()/(1024*1024));
                    }
                }

                System.out.println("over");
            }
        });
        t.start();
        while (true){
            Thread.sleep(1000);
            System.out.println("haha");
        }

    }
}
